package com.zhihaoliang.baseframe.db.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.zhihaoliang.baseframe.db.entity.CommentEntity;

import java.util.List;

/**
 * 创建日期：2020-02-24
 * 描述:评论的操作
 * 作者:支豪亮
 */
@Dao
public interface CommentDao {

    @Query("SELECT * FROM comments WHERE productId = :productId")
    LiveData<List<CommentEntity>> loadComments(int productId);

    @Query("SELECT * FROM comments WHERE productId = :productId")
    List<CommentEntity> loadCommentsSync(int productId);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<CommentEntity> comments);
}
